//
//  MainTableViewCell.m
//  明和智能
//
//  Created by 李李善 on 2018/8/24.
//  Copyright © 2018年 inno. All rights reserved.
//

#import "MainTableViewCell.h"

@implementation MainTableViewCell

-(void)onAsInitAddView:(UIView *)view forViewController:(UIViewController *)ViewController forDataSource:(id)dataSource AtIndexPath:(NSIndexPath *)indexPath
{
    self.backgroundColor = hexCOLOR(@"FAE5CA");
    UILabel *label = ({
        UILabel *l  = [UILabel new];
        l.text = @"公告";
        l.font = kSysFont(kFitW(10));
        l.textColor = hexCOLOR(@"C8731D");
        l.backgroundColor = hexCOLOR(@"FD9025");
        l.textAlignment = NSTextAlignmentCenter;
        
        [view addV:l];
        l;
    });
    
    UILabel *label1 = ({
        UILabel *l  = [UILabel new];
        l.text = @"过你放假通知!";
        l.font = kSysFont(kFitW(10));
        l.textColor = [UIColor blackColor];
        [view addV:l];
        l;
    });
    
    UIButton *v1 = ({
        UIButton *l = [UIButton buttonWithType:UIButtonTypeCustom];
        [l setNormalImage:[UIImage imageNamed:@"zhuye_delite_icon"]];
        l.tag =30;
        [l AddTarget:ViewController Action:@selector(onRightClick:)];
        //        [l setNormalBackImage:IMAGE(@"")];
        [view addV:l];
        l;
    });
    
    [self onMainSetSubViewFrame:^(UIView *view, CGPoint origin, CGSize size, CGPoint center) {
        label.size = CGSizeMake(kFitW(45),kFitH(25));
        label.left = kFitW(15);
        label.centerY = size.height/2;
        label.cornerRadius =kFitH(25)/2;
        [label masksToBounds];
        
        [label1 sizeToFit];
        label1.left = label.right+kFitW(15);
        label1.centerY = size.height/2;
        
        [v1 sizeToFit];
        v1.right=size.width-kFitW(15);
        v1.centerY = size.height/2;
        
    }];
}


- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end


@implementation MainTableViewCell1

-(void)onAsInitAddView:(UIView *)view forViewController:(UIViewController *)ViewController forDataSource:(id)dataSource AtIndexPath:(NSIndexPath *)indexPath
{
    NSArray *ar = @[@{@"imageName":@"zuye_tingc",@"title":@"入场停车"},
                    @{@"imageName":@"zuye_chuchang",@"title":@"出场缴费"},
                    @{@"imageName":@"zuye_yuyue",@"title":@"预约"},
                    @{@"imageName":@"zuye_hjiao",@"title":@"一键呼叫"},
                    ];
    NSMutableArray *arr = [NSMutableArray array];
    int o = 0;
    for (NSDictionary *dic in ar) {
        UIButton *yuan = ({
            UIButton *l  = [UIButton buttonWithType:UIButtonTypeCustom];
            [l setNormalTitle:dic[@"title"]];
            l.titleLabel.font = kSysFont(kFitW(12));
            [l setNormalTitleColor:[UIColor blackColor]];
            [l setNormalImage:[UIImage imageNamed:dic[@"imageName"]]];
            [view addV:l];
            l;
        });
        if (o==0||o==2) {
            yuan.hasRightLine = YES;
        }
       else if (o==1) {
            yuan.hasBottomLine = YES;
        }
        [arr addObject:yuan];
        o++;
    }
    
    [self onMainSetSubViewFrame:^(UIView *view, CGPoint origin, CGSize size, CGPoint center) {
        int m = 0;
        CGFloat w = size.width/3;
        CGFloat h = size.height/2;
        for (UIButton *btn in arr) {
            if (m==0) {
                btn.frame = CGRectMake(0, 0,w,size.height);
                [btn layoutButtonWithEdgeInsetsStyle:(MKButtonEdgeInsetsStyleTop) imageTitleSpace:3];
            }
            else if (m==1) {
                btn.frame = CGRectMake(w, 0,2*w,h);
                [btn layoutButtonWithEdgeInsetsStyle:(MKButtonEdgeInsetsStyleRight) imageTitleSpace:3];
            }
            else if (m==2) {
                btn.frame = CGRectMake(w,h,w,h);
                [btn layoutButtonWithEdgeInsetsStyle:(MKButtonEdgeInsetsStyleTop) imageTitleSpace:3];
            }
            else if (m==3) {
                btn.frame = CGRectMake(2*w,h,w,h);
                [btn layoutButtonWithEdgeInsetsStyle:(MKButtonEdgeInsetsStyleTop) imageTitleSpace:3];
            }
            m++;
        }
    }];
    
    
}
- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];
    
    // Configure the view for the selected state
}

@end


@implementation MainTableViewCell2

-(void)onAsInitAddView:(UIView *)view forViewController:(UIViewController *)ViewController forDataSource:(id)dataSource AtIndexPath:(NSIndexPath *)indexPath
{
    self.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
    self.textLabel.font = kSysFont(kFitW(12));
    self.detailTextLabel.font = kSysFont(kFitW(11));
    self.textLabel.text = @"公司简介";
    self.detailTextLabel.text = @"详情";
    
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];
    
    // Configure the view for the selected state
}

@end


@implementation MainTableViewCell3

-(void)onAsInitAddView:(UIView *)view forViewController:(UIViewController *)ViewController forDataSource:(id)dataSource AtIndexPath:(NSIndexPath *)indexPath
{
    self.imageView.image = [UIImage imageNamed:@"gongs"];
    WSELF(weakSelf);
    [self onMainSetSubViewFrame:^(UIView *view, CGPoint origin, CGSize size, CGPoint center) {
        weakSelf.imageView.frame = CGRectMake(0, 0, size.width, size.height);
    }];
}


@end

@implementation MainHeaderFooterView

-(void)onAsInitAddView:(UIView *)view forViewController:(UIViewController *)ViewController forDataSource:(id)dataSource AtSection:(NSInteger)section
{
    self.imageView.image = [UIImage imageNamed:@"banner"];
    WSELF(weakSelf);
    [self onMainSetSubViewFrame:^(UIView *view, CGPoint origin, CGSize size, CGPoint center) {
        weakSelf.imageView.frame = CGRectMake(0, 0, size.width, size.height);
    }];
}


@end
